/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 30318
 * Date: 2023-11-15
 * Time: 20:22
 */
import java.util.Scanner;

public class Menu {
    public static void main(String[] args) {
        boolean con = false;
        Administrator admin = new Administrator("满汉全席管理员","mhqx666666");//满汉全席管理员账户
        TestOfDesk testOfDesk = new TestOfDesk();
        do {
            System.out.println("*******************************");
            System.out.println("*******************************");
            System.out.println("******   欢迎来到满汉全席   ******");
            System.out.println("\t\t\t【1.客户端】");
            System.out.println("\t\t\t【2.商家端】");
            System.out.println("\t\t\t【3.退出】");
            System.out.println("*******************************");
            System.out.println("*******************************");
            System.out.println("请选择(输入1/2/3)：");
            Scanner input = new Scanner(System.in);
            if (input.hasNextInt()) {
                int num = input.nextInt();
                if (num == 1) {
                    boolean con1 = false;
                    do {
                        System.out.println("*******************************");
                        System.out.println("***********  客户端  ***********");
                        System.out.println("\t\t1. 选择菜单");
                        System.out.println("\t\t2. 预订位置");
                        System.out.println("\t\t3. 退订位置");
                        System.out.println("\t\t4. 会员信息");
                        System.out.println("\t\t5. 积分兑换");
                        System.out.println("\t\t6. 结账统计");
                        System.out.println("\t\t7. 返回上一级");
                        System.out.println("*******************************");
                        System.out.println("请选择：");
                        if (input.hasNextInt()) {
                            int num1 = input.nextInt();
                            switch (num1) {
                                case 1:
                                    FoodMenu foodMenu=new FoodMenu();
                                    foodMenu.PrintMune();
                                    break;
                                case 2:
                                    testOfDesk.bookDesk();
                                    break;
                                case 3:
                                    testOfDesk.cancelBooking();
                                    break;
                                case 4:
                                    ClientMember.main(null);
                                    break;
                                case 5:
                                    ChangeGoods changeGoods=new ChangeGoods();
                                    changeGoods.PointExchange();
                                    break;
                                case 6:
                                    Pay.main(null);
                                    break;
                                case 7:
                                    con1 = true;
                                    break;
                                default:
                                    System.out.println("输入错误");
                            }
                        }
                    }while(!con1);
                } else if (num == 2) {
                    if(admin.login()) {
                        boolean con2 = false;
                        do{
                            int d = 0;
                            System.out.println("*******************************");
                            System.out.println("***********  商家端  ***********");
                            System.out.println("\t\t1. 操作菜品");
                            System.out.println("\t\t2. 会员管理");
                            System.out.println("\t\t3. 桌子状态");
                            System.out.println("\t\t4. 接收订单查看");
                            System.out.println("\t\t5. 管理员信息修改");
                            System.out.println("\t\t6. 返回上一级页面");
                            System.out.println("*******************************");
                            System.out.println("请选择：");
                            if (input.hasNextInt()) {
                                int num2 = input.nextInt();
                                switch (num2) {
                                    case 1://菜品信息操作
                                        System.out.println("*******************************");
                                        TestFoodManagement.main(null);
                                        System.out.println("*******************************");
                                        System.out.println();
                                        break;
                                    case 2:
                                        System.out.println("*******************************");
                                        AdminMember.main(null);
                                        System.out.println("*******************************");
                                        System.out.println();
                                        break;
                                    case 3:
                                        System.out.println("*******************************");
                                        System.out.println("\t\t\t查看桌子状态");
                                        testOfDesk.displayAllDesk();
                                        System.out.println("*******************************");
                                        System.out.println();
                                        break;
                                    case 4:
                                        System.out.println("*******************************");
                                        System.out.println("\t\t\t接收订单查看");
                                        OrderingInfo orderingInfo = new OrderingInfo();
                                        orderingInfo.show();
                                        orderingInfo.displayOfOrder();
                                        System.out.println("*******************************");
                                        System.out.println();
                                        break;
                                    case 5:
                                        System.out.println("*******************************");
                                        System.out.println("\t\t管理员信息修改");
                                        System.out.println("请输入新的密码：");
                                        admin.setUserPWD(input.next());
                                        System.out.println("*******************************");
                                        System.out.println();
                                        break;
                                    case 6:
                                        con2 = true;
                                        break;
                                    default:
                                        System.out.println("输入错误");
                                }
                            }
                            if(d == -1) {
                                System.out.println("请输入\"n\"返回上一级");
                                char c = input.next().charAt(0);
                                while (c != 'n' && c != 'N') {
                                    System.out.println("请重新输入\"n\"返回上一级");
                                }
                            }
                        } while(!con2);
                    }
                } else if(num == 3) {
                    con = true;
                } else {
                    System.out.println("输入错误");
                }
            } else{
                System.out.println("输入错误");
            }
        }while(!con);
    }
}